<template>
  <div class="main-content">
    <el-carousel :z-index="3" :interval="4000" type="card" height="10rem">
      <el-carousel-item v-for="item in bannerList" :key="item.id">
        <img :src="url + item.pic">
      </el-carousel-item>
    </el-carousel>
    <p class="title mtb-40">歌手</p>
    <div class="grid">
      <ShowItemText @click="goSingerDetail(item)" v-for="item in singerList" :key="item.id" :sing="item" />
    </div>

    <p class="title mtb-40">歌单</p>
    <div class="grid">
      <ShowItemText @click="goSongDetail(item)" v-for="item in pageSongList" :key="item.id" :song="item" />

    </div>

  </div>
</template>

<script setup lang="ts">
import { ref, toRefs } from "vue"
import ShowItemText from "@/layout/components/ShowItemText.vue";
import { useSong } from "@/store/song.ts"
import { useUser } from "@/store/user.ts"
import { getBanner } from "@/fetch/song";
import { IBannerItem, ISingerItem, ISongItem } from "@/fetch/type";
import { getSingerList } from "@/fetch/singer";
import { useRouter } from "vue-router";
import { useDetail } from "@/utils/useDetail.ts"
import qs from "qs";
import Skeleton from "@/components/Skeleton/src/Skeleton.vue";

const { getAllSong, songList, pageSongList, getSongByPage } = toRefs(useSong())
getSongByPage.value()
const bannerList = ref<IBannerItem[]>([])
const singerList = ref<ISingerItem[]>([])
const url = import.meta.env.VITE_URL

// 获取轮播图
getBanner().then(({ data }) => {
  bannerList.value = data.data
})
//获取
getSingerList({ page: 1, pageSize: 10 }).then(({ data }) => {
  singerList.value = data.data.records
})

const { goSingerDetail, goSongDetail } = useDetail()

const { getUserList } = useUser()
getUserList()


</script>
<style lang="scss" scoped>
.main-content {
  padding: 0 2rem;
  color: var(--font-default-color);
}

.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>